#include<bits/stdc++.h>
using namespace std;
long long T,n,m,L,ans1,i,j,zz,k,flq,ll,rr,mid;
long double V,yqh,d[100001],a[100001],u[100001],p[100001];
bool o=0,oo;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&T);
    while(T--){
        vector<long double>l,r;
        scanf("%lld%lld%lld",&n,&m,&L);
        cin>>V;
        oo=0;
        for(i=1;i<=n;++i){
            cin>>d[i]>>u[i]>>a[i];
            if(a[i]<0)
                oo=1;
        }
        for(i=1;i<=m;++i)
            cin>>p[i];
        if(oo=1){
        yqh=-1;
        ans1=0;
        for(i=1;i<=n;++i){
            if(a[i]>=0){
                if(p[m]>=d[i])
                    if(sqrtl(u[i]*u[i]+2*a[i]*(p[m]-d[i]))>V){
                        ++ans1;
                        if(a[i]!=0)
                        yqh=max(yqh,d[i]+(V*V-u[i]*u[i])/(2*a[i]));
                        else
                        yqh=max(yqh,d[i]);
                    }
            }
            else if(a[i]<0){
                if(p[m]>=d[i])
                    for(j=1;j<=m;++j)
                        if(p[j]>=d[i])
                            if(sqrtl(u[i]*u[i]+2*a[i]*(p[j]-d[i]))>V){
                                ++ans1;
                            o=0;
                            for(k=0;k<l.size();++k){
                                if(l[k]<=d[i]&&r[k]>=d[i]+(V*V-u[i]*u[i])/(2*a[i])){
                                    o=1;
                                    break;
                                }
                                else  if(l[k]>=d[i]&&r[k]>=d[i]+(V*V-u[i]*u[i])/(2*a[i])){
                                    ll=1,rr=m;
                                    while(ll<=rr){
                                        mid=(ll+rr)>>1;
                                        if(p[mid]>=l[k]&&p[mid]<d[i]+(V*V-u[i]*u[i])/(2*a[i])){
                                           o=1;
                                           break;
                                        }
                                        else if(p[mid]<l[k])
                                           ll=mid+1;
                                        else
                                            rr=mid-1;
                                    }
                                    if(o==1){
                                        r[k]=d[i]+(V*V-u[i]*u[i])/(2*a[i]);
                                       break;
                                    }
                                }
                                 else  if(l[k]<=d[i]&&r[k]<=d[i]+(V*V-u[i]*u[i])/(2*a[i])){
                                    ll=1,rr=m;
                                    while(ll<=rr){
                                        mid=(ll+rr)>>1;
                                        if(p[mid]>=d[i]&&p[mid]<r[k]){
                                           o=1;
                                           break;
                                        }
                                        else if(p[mid]<d[i])
                                           ll=mid+1;
                                        else
                                            rr=mid-1;
                                    }
                                    if(o==1){
                                        l[k]=d[i];
                                        break;
                                    }
                                 }
                            }
                            if(o==0){
                                l.push_back(d[i]);
                                r.push_back(d[i]+(V*V-u[i]*u[i])/(2*a[i]));
                            }
                            break;
                        }
            }
        }
        for(i=0;i<l.size();++i)
            if(yqh<=r[i])
                yqh=-1;
        printf("%lld ",ans1);
        if(yqh==-1)
        printf("%lld\n",m-(long long )l.size());
        else
        printf("%lld\n",m-(long long )l.size()-1);
        }
        else {
             ans1=0;
        for(i=1;i<=n;++i)
            if(sqrtl(u[i]*u[i]+2*a[i]*(p[m]-d[i]))>V)
                ++ans1;
        if(ans1!=0)
            --m;
        printf("%lld %lld\n",ans1,m);
        }
    }
    return 0;
}
